﻿
/**
*封盘弹出表单
*/
Chenxin.UI.AdjournForm=Chenxin.extend(Chenxin.UI.FormCommon,{
	actionUrl:'service/LockedHandler.ashx',
	id:'adjournWin',
	renderTo:'jqm_adjourn',
	winCls:'',
	defBBtn:true,
	initFormValidator:function(){
		var _this=this;
        //初始化验证
		$("#f_startTime").focus(function() {
            WdatePicker({ oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        }).formValidator({ validatorgroup:this.id,
	        onshow: "请输入时间！", onfocus: "请输入时间", oncorrect: " "
	    }).inputValidator({
	        min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "时间不能为空！" }, onerror: "时间不能为空！"
	    }).functionValidator({ //数字验证
	        fun: function(val, elem) {
	            if ($("#f_startTime").val() != "" && $("#f_endTime").val() != "") {
	                var d1 = new Date(Date.parse($("#f_startTime").val().replace(/-/g, "/")));
	                var d2 = new Date(Date.parse($("#f_endTime").val().replace(/-/g, "/")));
	                if ((d1.getTime() - d2.getTime()) > 0) {
	                    return false;
	                } else {
	                    return true;
	                }
	            }
	        }, onerror: "开始时间不能大于结束时间"
	    });
	    
	    $("#f_endTime").focus(function() {
            WdatePicker({ oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        }).formValidator({ validatorgroup:this.id,
	        onshow: "请输入时间！", onfocus: "请输入时间", oncorrect: " "
	    }).inputValidator({
	        min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "时间不能为空！" }, onerror: "时间不能为空！"
	    });

	    $("#f_descript").formValidator({ validatorgroup: this.id,
	        onshow: "", onfocus: "", oncorrect: " "
	    }).inputValidator({
	        min: 1, empty: { emptyerror: "描述不能为空！" }, onerror: "描述不能为空！"
	    });
	    
	    $("#f_workcode").formValidator({ validatorgroup:this.id, onshow: "请输入工号！", onfocus: "请输入工号！", oncorrect: "输入正确" }).inputValidator({
	        min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "工号不能为空!" }, onerror: "工号不能为空!"
	    }).ajaxValidator({
	        url: "service/LockedHandler.ashx",
	        datatype: "json",
	        data: "&op=validate",
	        success: function(data) {
				if(data.success==0){
					$('#f_name').val('');
					$('#f_department').val('');
	                return false;
				}else{		
					$('#f_name').val(data.data.model.UserName);
					$('#f_department').val(data.data.model.DepartName);
	                return true;
				}
	        },
	        buttons: $("#adjourn_Save"),
	        error: function() { alert("服务器没有返回数据，可能服务器忙，请重试"); },
	        onerror: "工号不存在！",
	        onwait: "正在校验，请稍候..."
	    });
	},
	
	createForm:function(){
		//return formCommon.houseAdjournForm('adjourn');
		return Chenxin.FormCommon.houseAdjournForm('adjourn');
		
	},
	initEvent:function(){
		var _this=this;
		$('#adjourn_Save').live('click',function(){
			_this.save();
		});
		$('#adjourn_Cancle').live('click',function(){
			_this.hide();
		});
	},
	initComponent:function(){
		Chenxin.UI.AdjournForm.superclass.initComponent.call(this);
	}	
});


    /**
    *@description 房屋封盘表单
    *@comboIdPrefix DIV下拉框和提交按钮前缀
    */
Chenxin.FormCommon.houseAdjournForm=function(comboIdPrefix) {
    return '<table class="tbl_f jqTabWh"><tbody> <tr><th>房源编号：</th><td id ="f_houseCode" ><input type="text" name="HouseCode" class="inputbox_n" readonly="readonly" /></td></tr><tr><th>地址：</th><td><input type="text" name="Address" class="inputbox_n" readonly="readonly" /></td></tr><tr><th>所属人员：</th> <td><input type="text" name="AddPerson" class="inputbox_n" readonly="readonly" /></td></tr><tr><th>所属门店：</th> <td><input type="text" name="AddDepart" class="inputbox_n" readonly="readonly" /></td></tr><tr><th>开始时间：</th> <td colspan="3"> <div style="float:left;"><input name="LockedTime" readonly="readonly"  class="inputbox_n" id="f_startTime" type="text" /></div><div style="float:left" id="f_startTimeTip"/></td></tr><tr><th>结束时间：</th><td><div style="float:left;"><input name="LastTime" readonly="readonly"  class="inputbox_n" id="f_endTime" type="text" /></div><div style="float:left" id="f_endTimeTip"/></td></tr><tr><th>工号：</th><td><div style="float:left"><input name="workcode" id="f_workcode"  maxlength="20" class="inputbox_n" type="text" /></div><div style="float:left" id="f_workcodeTip" /></td></tr> <tr><th>姓名：</th><td><input name="Asker" class="inputbox_n" readonly="readonly" type="text" id ="f_name" /></td></tr><tr><th>门店：</th> <td><input name="AskerDepart" readonly="readonly" class="inputbox_n" type="text" id ="f_department" /></td></tr><tr><th>封盘描述：</th> <td colspan="3"><textarea name="Remarks" onkeypress="if (this.value.length>=200){event.returnValue=false}"  onchange="if (this.value.length>=200){this.value=this.value.substr(0, 200)}"  id ="f_descript" cols="80" rows="3" class="textarea_n" style="width:450px; height: 100px; padding:5px;"></textarea></td></tr></tbody> </table>';
};